<template>
  <el-checkbox-group v-model="checkList" @input="onInputSelect">
    <el-checkbox v-for="item in options" :key="item.id" :label="item.id">{{ item.codName }}</el-checkbox>
  </el-checkbox-group>
</template>
<script>
export default {
  // eslint-disable-next-line vue/require-prop-types
  props: ['multi', 'name', 'label', 'value', 'disabled', 'optionsurl'],
  data() {
    return {
      checkList: this.value,
      options: []
    }
  },
  watch: {
    value() {
      //   this.currentValue = this.value
    }
  },
  created() {
    // this.currentValue = this.value
    this.queryAction()
  },
  methods: {
    onInputSelect(value) {
      const pravmas = this.options.filter(i => value.indexOf(i.id) > -1)
      // console.log(pravmas)
      this.$emit('input', this.name, pravmas)
    },
    queryAction() {
      // console.log(this.optionsurl)
      this.api[this.optionsurl]({})
        .then(res => {
          this.options = res
        })
        .finally(() => {
          this.pagelistLoading = false
        })
    }
  }
}
</script>

